package cn.mw.cmdb.entity;

import com.alibaba.nacos.common.utils.CollectionUtils;
import com.google.common.base.Strings;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 组件选择下拉监控数据
 */
@Data
public class MwLayoutItemDropInfo {
    @Schema(description = "应用集")
    private String applicationName;
    @Schema(description = "监控项接口")
    private List<String> interfaceDrops;
    @Schema(description = "监控项信息")
    private List<ItemDropInfo> itemInfos;
    @Schema(description = "自定义名称")
    private String customName;

    public List<String> getItemDrop(){
        List<String> list = new ArrayList<>();
        if(CollectionUtils.isNotEmpty(itemInfos)){
            list = itemInfos.stream().filter(s-> !Strings.isNullOrEmpty(s.getName())) .map(s -> s.getName()).collect(Collectors.toList());
        }
        return list;
    }
}
